local httparg    = require("shared.api.httparg")
local response   = require("shared.api.response")
local tag        = httparg.tag()
local assertion  = httparg.assertion


local ARGS = {
  -- exist body?
  tag.body('json', 'required'),

  username  = tag.json.username      ('string', 'required', assertion.non_empty_string()),
  alliance  = tag.json.alliance      ('string',             assertion.non_empty_string()),
  locale    = tag.json.locale        ('string',             assertion.non_empty_string()),
}



local RESULT
do
  local dataapi   = require("shared.api.dataapi")

  local reply, err = dataapi.account.view_level(
    {
      username   = ARGS.username,
      alliance   = ARGS.alliance,
      locale     = ARGS.locale,
    })

  if err then
    response.error(err)
  end

  -- export
  RESULT = reply
end

-- response
response.success(RESULT)
